import os
import sys
sys.path.append(".")

import pyarma as pa

from unifuncs import *

def EulerS2(u0, u1, h, A, g):

    return u1 + h * pv.phiv(h * A, [g(u1) + A * u1, g(u1) - g(u0)])

def RosenbrockS2(u0, u1, h, J, F):

    Jn = J(u1)
    gn = lambda u: F(u) - Jn * u
    return u1 + h * pv.phiv(h * Jn, [F(u1), - (2 / 3) * (gn(u1) - gn(u0))])

def RosenbrockS3(u0, u1, h, J, F):

    Jn = J(u1)
    gn = lambda u: F(u) - Jn * u
    return u1 + h *pv.phiv(h * Jn, [F(u1), pa.zeros(pa.size(u0)), -2 * (gn(u1) - gn(u0))])

